use leptos::prelude::*;
use icondata as i;
use serde_json::Value;
use thaw_utils::ArcOneCallback;
#[derive(Clone)]
pub struct ButtonProp {
    pub text: String,
    pub icon: i::Icon,
    pub on_click: ArcOneCallback<Vec<(String,Value)>>,
}
impl ButtonProp {
    pub fn new(
        text: String,
        icon: i::Icon,
        on_click: ArcOneCallback<Vec<(String,Value)>>,
    ) -> Self {
        Self {
            text,
            icon,
            on_click,
        }
    }
    pub fn from_close(
        text: Option<String>,
        icon: Option<i::Icon>,
        show_modal: RwSignal<bool>,
    ) -> Self {
        ButtonProp::new(
            text.unwrap_or("关闭".to_string()),
            icon.unwrap_or(i::AiCloseCircleOutlined),
            ArcOneCallback::new(move |_| {
                show_modal.set(false);
            }),
        )
    }
}
